package cn.ffcs.util.converter;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Map;
import ognl.DefaultTypeConverter;
import ognl.ParseException;

public class StringConverter extends DefaultTypeConverter 
{
    private static final SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");  
    
    public Object convertValue(Map ognlContext, Object value, Class toType) {           
        Object result = null;  
        if (toType == String.class) {  
            result = doConvertToString(value);  
        }else{
            result=value;
        }
        
       return result;  
   }  
 
   private String doConvertToString(Object value) {  
       String result = null;  
       if (value instanceof String) {  
           result =(String)value;  
           result=result.replaceAll("\n", "<br/>");
           result=result.replaceAll(" ", "&nbsp;");
       }  
       return result;  
   }  
}
